package controls;

import java.util.ArrayList;

import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.scene.Mesh;
import com.jme3.texture.Texture;

/*
 * Contains basic methods, variables for all state machines that control the appearance
 * of objects in-game.  These state machines receive events or examine the state of
 * the spatial they're attached to and modify its appearance accordingly.
 */
public abstract class AbstractViewStateMachineControl extends AbstractGameControl {
	
	protected ArrayList<String> viewStates = new ArrayList<String>();
	protected String currState;
	protected String[] states;
	protected Material[] materials;
	protected Texture[] textures;
	protected Mesh[] meshes;
	protected AssetManager assetManager;
	
	public AbstractViewStateMachineControl(AssetManager assetManager, int numStates) {
		initArrays(numStates);
		defineSpatialStates();
		this.assetManager = assetManager;
		loadStates(states);
	}
	
	public void initArrays(int dim) {
		states = new String[dim];
		materials = new Material[dim];
		textures = new Texture[dim];
		meshes = new Mesh[dim];
	}
	
	public boolean contains(String state) {
		return viewStates.contains(state);
	}
	
	public abstract void changeState(String newState);
	
//	public void addState(String state) {
//		this.viewStates.add(state);
//	}
	
	/**
	 * Used to reset current view state back to default, starting state
	 */
	public abstract void resetToDefault();
	
	
	public void loadStates(String[] states) {
		viewStates.clear();		
		for (int i = 0; i < states.length; i++) {
			viewStates.add(states[i]);
		}
	}
	
	/**
	 * Inheriting classes list all states, materials, textures, meshes here
	 */
	public abstract void defineSpatialStates();
}
